//
// Created by 86131 on 2023/9/9.
//
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define SHUJUJIEGUO_二分查找_H
//typedef int Position;
using namespace std;
#define MAXSIZE 10
//typedef enum {false, true} bool;
typedef int ElementType;
typedef int Position;
#define MAXSIZE 10
typedef struct LNode *List;
struct LNode{
    ElementType Data[MAXSIZE];
    Position Last;/* 保存线性表中最后一个元素的位置 */
};
List ReadInput(); /* 读入线性表。元素从下标0开始存储 */
void PrintList( List L ); /* 输出线性表 */
Position ef(List L1,List L2);
int main(){
    List L1;
    List L2;
    ElementType X;
    L1 = ReadInput();
    L2 = ReadInput();
    cout<<ef(L1,L2);
}

List ReadInput(){
    List L;
    L = static_cast<List>(malloc(sizeof(struct LNode)));
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>L->Data[i];
    }
    L->Last=n-1;
    return L;
}
void PrintList( List L ){
    for(int i=0;i<L->Last;i++){
        cout<<L->Data[i]<<" ";
    }
    free(L);
}
Position ef(List L1, List L2){
       int c=0;
       int i1=0;
       int i2=0;
       int s;
       while(c<(L1->Last+L2->Last)/2-1){
           if(L1->Data[i1]>L1->Data[i2]){
               s = L1->Data[i1];
               i1++;
               c++;
           }else{
               s = L2->Data[i2];
               i2++;
               c++;
           }
       }
    return s;
}